<template>
  <div class="tab2_wrap">
    <div class="tab2_topheader">
      <div class="btn_wrap">
        <el-button type="primary" size="small">新增</el-button>
        <el-button type="danger" size="small">批量删除</el-button>
      </div>
    </div>
    <div class="tab2_main">
      <el-table :data="tableData" style="width: 100%">
        <el-table-column type="selection" width="55"> </el-table-column>
        <el-table-column prop="nameStr" label="名称">
          <template slot-scope="scope">
            {{ scope.row }}
            <el-input v-model="scope.row.nameStr"></el-input>
          </template>
        </el-table-column>
        <el-table-column prop="codeStr" label="编码">
          <template slot-scope="scope">
            <el-input v-model="scope.row.codeStr"></el-input>
          </template>
        </el-table-column>
        <el-table-column prop="typeStr" label="数据类型">
          <template slot-scope="scope">
            <el-input v-model="scope.row.typeStr"></el-input>
          </template>
        </el-table-column>
        <el-table-column prop="lengthStr" label="长度">
          <template slot-scope="scope">
            <el-input v-model="scope.row.lengthStr"></el-input>
          </template>
        </el-table-column>
        <el-table-column prop="jingdu" label="精度">
          <template slot-scope="scope">
            <div slot="reference" class="name-wrapper">
              <p v-if="!scope.row.isEdit">{{ scope.row.jingdu }}</p>
              <el-input
                v-if="scope.row.isEdit"
                v-model="scope.row.jingdu"
              ></el-input>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="default" label="默认值">
          <template slot-scope="scope">
            <div slot="reference" class="name-wrapper">
              <p v-if="!scope.row.isEdit">{{ scope.row.default }}</p>
              <el-input
                v-if="scope.row.isEdit"
                v-model="scope.row.default"
              ></el-input>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="可空">
          <template slot-scope="scope">
            <el-checkbox-group v-model="scope.row.emptyAble">
              <el-checkbox
                label=""
                name="type"
                :disabled="!scope.row.isEdit"
              ></el-checkbox>
            </el-checkbox-group>
          </template>
        </el-table-column>
        <el-table-column prop="desc" label="描述">
          <template slot-scope="scope">
            <div slot="reference" class="name-wrapper">
              <p v-if="!scope.row.isEdit">{{ scope.row.desc }}</p>
              <el-input
                v-if="scope.row.isEdit"
                v-model="scope.row.desc"
              ></el-input>
            </div> </template
        ></el-table-column>
        <el-table-column label="操作" width="100" v-if="actionTag !== 'view'">
          <template slot-scope="scope">
            <el-button
              v-if="!scope.row.isEdit"
              @click="edit(scope.row)"
              type="text"
              size="small"
            >
              编辑
            </el-button>
            <el-button
              v-if="scope.row.isEdit"
              @click="baocunrow(scope.row)"
              type="text"
              size="small"
            >
              保存
            </el-button>
            <el-button @click="del(scope.row)" type="text" size="small">
              删除
            </el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    propsData: {
      type: Object,
      default: () => {},
    },
  },
  watch: {
    propsData: {
      deep: true,
      handler(val) {
        if (val.tab12?.jiegouArr?.length > 0) {
          this.tableData = JSON.parse(JSON.stringify(val.tab12.jiegouArr));
        } else {
          this.tableData = [];
        }
      },
    },
  },
  data() {
    return {
      tableData: [],
    };
  },
  beforeDestroy() {},
  created() {},
  mounted() {},
  methods: {},
};
</script>

<style lang="less" scoped></style>
